package com.example.test;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.example.test.bean.GW;
import com.example.test.bean.TW;

public class MySQLiteOpenHelper_2 extends SQLiteOpenHelper {
    private static final String DB_NAME= "mySQLite.db";
    private static final String TABLE_NAME_TW = "TW";
    private static final String CREATE_TABLE_SQL = "create table " +TABLE_NAME_TW + "(id integer primary key autoincrement, carNumber_2 text,date_2 text,w_2 text)";

    public MySQLiteOpenHelper_2(Context context){
        super(context, DB_NAME, null,1);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TABLE_SQL);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    public long insertData(TW tw){
        SQLiteDatabase db = getWritableDatabase();
        ContentValues values = new ContentValues();
        values.put("carNumber_2",tw.getCarNumber_2());
        values.put("date_2",tw.getDate_2());
        values.put("w_2",tw.getW_2());
        return db.insert(TABLE_NAME_TW,null,values);
    }
}
